#ifndef GUARD_H
#define GUARD_H

// Guard pattern (GoF) for handling locking/unlocking of _mutex
class Guard 
{

public:
	Guard(Thread_Mutex *_mutex)
	{
		hMutex = _mutex;
		acquire();
	}

	virtual ~Guard() 
	{
		release();
	}

	void release()
	{
		hMutex->signal();
	}

	void acquire()
	{
		hMutex->wait();
	}

private:
	Thread_Mutex *hMutex;
};

#endif